<!DOCTYPE html>
<html lang="zh-cn">
<head>
<include file="Widget/head" />
<link rel="stylesheet" type="text/css" href="__CSS__/Home/defaut.css">
<link rel="stylesheet" type="text/css" href="__CSS__/Home/distance.css">
<link rel="stylesheet" type="text/css" href="__CSS__/Home/button.css">
<link rel="stylesheet" type="text/css" href="__CSS__/Home/font.css">
<link href="__CSS__/Home/global.css" rel="stylesheet" type="text/css">
<link href="__CSS__/Home/member.css" rel="stylesheet" type="text/css">
</head>

<body style="zoom: 1;">
{:W('Page/menu')}

<div class="contt">
	<div class="redbg">
	<form action="{:U('Index/duanxin')}" method="post" onsubmit="return checkform(this);">
		<div class="regtb">
		<table width="100%" border="0" cellspacing="0" cellpadding="0">
		<tbody>
		<tr>
            <td width="8%"><label for="reg_code">平台账户：</label></td>
            <td width="92%">&nbsp;&nbsp;<b><span id="userName">{$session_user['account']}</span></b></td>
        </tr>
        <tr>
            <td><label for="reg_code">绑定手机号：</label></td>
            <td>&nbsp;&nbsp;<b style="font-size:18px; color:#000;&gt;" >
            	<input type="text" class="form-control" id="mobile" name="mobile"placeholder="请输入手机号码" readonly= "true"  value="{$session_user['mobile']}">
            </b></td>
        </tr>
        <tr>
            <td><label for="reg_code">验证码：</label></td>
            <td><input type="text" class="yanzhenma" id="verify" name="verify"placeholder="验证码">
            	<img id="verifyIMG" src="{:U('Index/verify')}" onclick="imgClick();" height="34px;">
        </tr>
        <!--手机验证-->
                    
        <tr>
            <td>短信码：</td>
            <td>
                <input type="text" class="form-control" id="phoneverify" name="phoneverify" placeholder="手机验证码">
                <button id="sendvf" class="btn btn-info" style="width:100%;">点击获取</button>
                <strong class="high"> *</strong>
            </td>
        </tr>
        
        <!--手机验证-->
        <tr><td></td><td><input type="submit" value="提交验证" id="sendyz" class="smrzbt" style=" background-image:none; padding-left:0px;"></td></tr>
		</tbody></table>
		</div>
	</form>	
	</div>
</div>
<script type="text/javascript">
function checkform(){
	if($("#verify").val() == ""){	alert("请输入图片验证码！");return false;	}
	if($("#phoneverify").val() == ""){	alert("请输入短信验证码！");return false;	}
}

function imgClick() {
	$("#verifyIMG").attr('src',"{:U('Index/verify')}?"+ Math.random());
}
$(function($) {

	$("#sendvf").click(function(){
		$("#formErr").hide();
		var thisbtn = $(this);
		var preg = new RegExp(/^1\d{10}$/);
		if (preg.test($("#mobile").val())) {
			//倒计时开始
			thisbtn.attr("disabled", "disabled");
			var wait = 60;
			thisbtn.html("重新发送（"+wait+"）")
			var interval = setInterval(function(){
				wait = --wait;
				if(wait <= 0) {
					thisbtn.html("点击获取验证码")
					thisbtn.removeAttr("disabled");
					clearInterval(interval);
				}else {
					thisbtn.html("重新发送（"+wait+"）")
				}
			}, 1000);
			// 发送验证码
			
			$.ajax({
				cache: false,
				type:  "post",
				url: "{:U('sendVerify')}",
				data: {phone:$("#mobile").val(),check:'0'},
				//async: false, //同步请求, 其它操作必须等待请求完成才可以执行
				success: function(dd) {
					if (dd.status == 1) {
						//成功
						$("#formErr").hide();
					}else {
						$("#formErr").html(dd.info);
						$("#formErr").show();
						thisbtn.html("点击获取验证码")
						thisbtn.removeAttr("disabled");
						clearInterval(interval);
					}
				}
			});
			
		}else {
			if ($("#mobile-error").length>0) {
				$("#mobile-error").show();
			}else {
				$("#mobile").after('<label id="mobile-error" class="error" for="mobile" style="display: inline-block;">请输入正确的手机号码！</label>');
			}
		}
		
		return false;
	});
});
</script>
{:W('Page/foot')}
</body>
</html>